﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmallERP.MODEL.PaperManager
{
    public class PaperInfo_Info
    {
        public int PaperId { get; set; }
        public string PaperTypeName { get; set; }
        public string PaperFaceName { get; set; }
        public double Length { get; set; }
        public double Width { get; set; }
        public DateTime AddTime { get; set; }
        public DateTime LastPrintTime { get; set; }
        public int PrinterId { get; set; }
        public int Status { get; set; }
        public string StatusName
        {
            get
            {
                string strStatusName = string.Empty;
                switch (Status)
                {
                    case (int)SmallERP.COM.Status.PaperInfoStatus.Complete:
                        strStatusName = "完成";
                        break;
                    case (int)SmallERP.COM.Status.PaperInfoStatus.Using:
                        strStatusName = "正在打印";
                        break;
                    case (int)SmallERP.COM.Status.PaperInfoStatus.Used:
                        strStatusName = "使用一部份";
                        break;
                    case (int)SmallERP.COM.Status.PaperInfoStatus.New:
                        strStatusName = "还未使用";
                        break;
                    default:
                        break;
                }

                return strStatusName;
            }
        }
        /// <summary>
        /// 整轴纸面积
        /// </summary>
        public double TotalArea { get { return Length * Width; } }
        /// <summary>
        /// 浪费总面积
        /// </summary>
        public double WrasteArea { get { return WateLength * Width; } }
        /// <summary>
        /// 有效面积
        /// </summary>
        public double AvailabilityAread { get { return TotalArea - WrasteArea; } }
        /// <summary>
        /// 有效百分比        /// 
        /// </summary>
        public double AvailabilityPer { get { return (1 - (WrastePer/100))*100; } }
        /// <summary>
        /// 浪费百分比
        /// </summary>
        public double WrastePer { get { return (WateLength / Length) * 100; } }
        /// <summary>
        /// 浪费的长度
        /// </summary>
        public double  WateLength { get; set; }

        /// <summary>
        /// 打印了板的面积
        /// </summary>
        public double PrintBoardArea { get; set; }


        /// <summary>
        /// 条码和白边的浪费面积
        /// </summary>
        public double BarCodeAndBBArea { get; set; }

        /// <summary>
        /// 当出片面积加上浪费面积小于总面积时就证明这轴纸有问题，反之变然
        /// </summary>
        public bool IsRight
        {
            get
            {
                if (PrintBoardArea+WrasteArea>=TotalArea)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }

        public List<PaperRecords_Info> UseRecords { get; set; }

        /// <summary>
        /// 是否所有的费纸都确认完成
        /// </summary>
        public string IsAllChecked
        {
            get
            {
                if (UseRecords.Count(p=>p.Status!=(int)SmallERP.COM.Status.WasterPaperStatus.Sure)>0)
                {
                    return "未完成";
                }
                else
                {
                    return "完成";
                }
            }
        }
    }
}
